<?php
session_start();
$title="แก้ไขผู้ใช้";
include ('header-admin.php');

$userID=$_SESSION["HBD_USER"];

$userlist_id=$_GET["userlist_id"];
//fetch userdata
$sql="SELECT userlist_id,userlist_username,userlist_name,userlist_surname,userlist.group_id FROM `userlist`,`group` WHERE userlist.group_id=group.group_id AND userlist_id = $userlist_id";
$result = mysql_query($sql);
$rs = mysql_fetch_array($result);
$userlist_username = $rs[userlist_username];
$userlist_password = $rs[userlist_password];
$group_id = $rs[group_id];
$userlist_name = $rs[userlist_name];
$userlist_surname = $rs[userlist_surname];
?>

<div id="center-block" class="main-content">
<img src="img/register.png"/ id="img-block-content">
<div id="content-title-right">
		<h2 class="caption-header">แก้ไขผู้ใช้</h2>
		<span class="caption">* ถ้าไม่ต้องการเปลี่ยนรหัสผ่าน ไม่ต้องใส่รหัสผ่าน</span>
	</div>

	<hr><br><br><br><br><br>
			<div id="center-block-right">
				<form action="doEditUser.php?userlist_id=<?=$userlist_id?>" method="POST" id="booking-form">				
					<table>
						<tr>
							<td><label for="userlist_username">Username</label></td>
							<td><input type="text" id="userlist_username" name="userlist_username" value="<?=$userlist_username?>" size="15" class="validate[required] text-input" disabled/></td>
							<td></td>
						</tr>
						<tr>
							<td><label for="userlist_password">รหัสผ่านใหม่</label></td>
							<td><input type="password" id="userlist_password" name="userlist_password" value="" size="15"/></td>
							<td></td>
						</tr>
						<tr>
							<td><label for="userlist_repassword">ยืนยันรหัสผ่านใหม่</label></td>
							<td><input type="password" id="userlist_repassword" name="userlist_repassword" value="" size="15" class="validate[confirm[userlist_password]] text-input"/></td>
							<td></td>
						</tr>
						<tr>
							<td><label for="group_id">กลุ่มผู้ใช้</label></td>
							<td><select name="group_id" id="group_id" style="width: 120px" class="validate[required] text-input">
								   <option value="">---</option>
									<?
									$sql="SELECT * FROM `group` ORDER BY `group_id` ASC";
									$result = mysql_query($sql);	
									while ($rs = mysql_fetch_array($result)){
										if($group_id==$rs[group_id])
											echo '<option value="' . $rs[group_id] . '" SELECTED>' . $rs[group_name] . '</option>';
										else
											echo '<option value="' . $rs[group_id] . '">' . $rs[group_name] . '</option>';
									}
										
									?>
								</select></td>
							<td></td>
						</tr>
						<tr>
							<td><label for="userlist_name">ชื่อ-นามสกุล</label></td>
							<td><input type="text" id="userlist_name" name="userlist_name" value="<?=$userlist_name?>" size="20" class="validate[required] text-input"/></td>
							<td><input type="text" id="userlist_surname" name="userlist_surname" value="<?=$userlist_surname?>" size="20" class="validate[required] text-input"/></td>
						</tr>
						<tr>
							<td colspan="3"><br/></td>
						</tr>
						<tr>
							<td></td>
							<td><p class="submit"><input type="submit" value="เรียบร้อย" /></p></td>
							<td></td>
						</tr>
					</table>
				</form>
				<br><br>
			</div>
	</div>

<?
include ('footer.php');
?>